<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta content="IE=edge" http-equiv="X-UA-Compatible">
    <title>传智健康</title>
    <meta content="传智健康" name="description">
    <meta content="传智健康" name="keywords">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link href="../plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
    <script src="../plugins/echarts/echarts.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">

    <!-- 引入组件库 -->
    <script src="../js/jquery.min.js" type="text/javascript"></script>
    <script src="../js/vue.js"></script>
    <!-- 引入组件库 -->
    <script src="../js/axios-0.18.0.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>统计分析<small>会员数量</small></h1>
        <el-breadcrumb class="breadcrumb" separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员数量</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <div class="block">
                <el-date-picker
                        v-model="value2"
                        type="monthrange"
                        align="right"
                        unlink-panels
                        range-separator="至"
                        start-placeholder="开始月份"
                        end-placeholder="结束月份"
                        :picker-options="pickerOptions">
                </el-date-picker>
                <el-button @click="findInfo()" class="dalfBut">查询</el-button>
            </div>
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:500px;"></div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例


    // 使用刚指定的配置项和数据显示图表。
    //myChart.setOption(option);
    let vue = new Vue({
        el:"#app",
        data:{

        },
        data() {
            return {
                pickerOptions: {
                    shortcuts: [{
                        text: '本月',
                        onClick(picker) {
                            picker.$emit('pick', [new Date(), new Date()]);
                        }
                    }, {
                        text: '今年至今',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date(new Date().getFullYear(), 0);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近六个月',
                        onClick(picker) {
                            const end = new Date();
                            const start = new Date();
                            start.setMonth(start.getMonth() - 6);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                value2: ''
            };
        },
        methods:{
            findInfo(){
            // alert(this.value2);
            let myChart1 = echarts.init(document.getElementById('chart1'));
            axios.post("/report/getMemberReportByTime.do",this.value2).then((res)=>{
                myChart1.setOption(
                    {
                        title: {
                            text: '会员数量'
                        },
                        tooltip: {},
                        legend: {
                            data: ['会员数量']
                        },
                        xAxis: {
                            data: res.data.data.months
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            name: '会员数量',
                            type: 'line',
                            data: res.data.data.memberCount
                        }]
                    });
            })
        }
        },
        mounted() {
            let myChart1 = echarts.init(document.getElementById('chart1'));
            axios.get("/report/getMemberReport.do").then((res) => {
                myChart1.setOption(
                    {
                        title: {
                            text: '会员数量'
                        },
                        tooltip: {},
                        legend: {
                            data: ['会员数量']
                        },
                        xAxis: {
                            data: res.data.data.months
                        },
                        yAxis: {
                            type: 'value'
                        },
                        series: [{
                            name: '会员数量',
                            type: 'line',
                            data: res.data.data.memberCount
                        }]
                    });
            });
        }
    });
</script>
</html>
